package com.jzo2o.customer.controller.operation;

import com.jzo2o.common.model.PageResult;
import com.jzo2o.customer.model.dto.request.AgencyCertificationAuditPageQueryReqDTO;
import com.jzo2o.customer.model.dto.response.AgencyCertificationAuditResDTO;
import com.jzo2o.customer.service.IAgencyCertificationAuditService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author itcast
 */
@RestController("operationAgencyCertificationAuditController")
@RequestMapping("/operation/agency-certification-audit")
@Api(tags = "机构端 - 机构端审核认证接口")
public class AgencyCertificationAuditController {

    @Resource
    private IAgencyCertificationAuditService agencyCertificationAuditService;

    /**
     * 4.2.3.3 审核机构认证分页查询
     */
    @GetMapping("/page")
    @ApiOperation("审核机构认证分页查询")
    public PageResult<AgencyCertificationAuditResDTO> page(AgencyCertificationAuditPageQueryReqDTO agencyCertificationAuditPageQueryReqDTO) {
        return agencyCertificationAuditService.pageAgencyCertificationAudit(agencyCertificationAuditPageQueryReqDTO);
    }

    /**
     * 4.2.3.4 审核机构认证信息
     */
    @PutMapping("/audit/{id}")
    @ApiOperation("审核机构认证分页查询")
    public void audit(@PathVariable("id") Integer id,
                      @RequestParam("certificationStatus") Integer certificationStatus,
                      @RequestParam(value = "rejectReason", required = false) String rejectReason) {
        if (rejectReason == null) {
            rejectReason = "";
        }
        agencyCertificationAuditService.audit(id,certificationStatus,rejectReason);
    }
}
